Skip to content

Add cla support#1026

Draft
jt-nti wants to merge 1 commit into
openpolitics:mainfrom
jt-nti:user-cla
Draft

Add cla support#1026
jt-nti wants to merge 1 commit into
openpolitics:mainfrom
jt-nti:user-cla

Conversation

@jt-nti

@jt-nti jt-nti commented Feb 15, 2021

Copy link
Copy Markdown
Collaborator

Signed-off-by: James Taylor jt-git@nti.me.uk

@jt-nti

jt-nti commented Feb 15, 2021

Copy link
Copy Markdown
Collaborator Author

Not finished yet but is this along the right lines for #72 @Floppy?

@Floppy

Floppy commented Feb 16, 2021

Copy link
Copy Markdown
Member

That looks good to me, feels like it's going the right way.

@jt-nti

jt-nti commented Feb 16, 2021

Copy link
Copy Markdown
Collaborator Author

Great, I'll keep going in that case. Currently wondering how to make a button actually update the CLA setting (and refresh the proposal).

@jt-nti jt-nti force-pushed the user-cla branch 3 times, most recently from 99a7835 to 98699ab Compare February 19, 2021 15:31

# TODO this takes a while
# Can the proposal states be updated in the background?
@user.proposed.each do |pr|

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Floppy any idea how to make this happen in the background or is it not worth worrying about? (There's a noticeable delay, especially if you have lots of PRs open but that's unlikely in normal circumstances I guess.)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, there's a background job runner that will do it. If you do UpdateProposalJob.perform_later pr.number I think that will work.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, that was a lot easier than I was expecting! Thanks.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Helps that I had basically the exact same problem a while back :)

@jt-nti

jt-nti commented Feb 19, 2021

Copy link
Copy Markdown
Collaborator Author

@Floppy I think it's mostly working now- probably needs some tests though!!

@jt-nti jt-nti force-pushed the user-cla branch 4 times, most recently from a95b93d to 72389df Compare February 22, 2021 20:54

@Floppy Floppy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks very nice. Made a few suggestions around DRYing up the code a little, but in general this looks great :)

Comment thread app/controllers/proposals_controller.rb Outdated
# Get activity list
presenter = ProposalPresenter.new(@proposal)
@activity = presenter.activity_log
# Does the proposer still need to sign the CLA?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this is in both here and the edit controller, it feels like it could be pushed into the User model?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was bugging me as well, I'll move it

set_build_status(:pending, I18n.t("build_status.cla.pending"), status)
end
else
set_build_status(:success, I18n.t("build_status.cla.none"), status)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to set the build status at all if there's no CLA? Probably not...

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, I hadn't thought of just not adding it, doh!

Comment thread app/models/proposal.rb Outdated
return nil if pr_closed?
return "dead" if too_old?
return "blocked" if blocked?
return "blocked" if blocked? || (cla_required? && !cla_accepted?)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic happens quite a lot. I feel like there's a combined method like User#needs_to_sign_cla? that would reduce the places where both have to be checked.

@jt-nti jt-nti force-pushed the user-cla branch 2 times, most recently from e651835 to 6b3b7be Compare February 24, 2021 21:47
Signed-off-by: James Taylor <jt-git@nti.me.uk>
Base automatically changed from master to main March 2, 2021 09:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants